<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js">/*
 * Copyright (c) 2016 JUI All rights reserved.
 */

;(function () {

<span id=''>    /**
</span>     * @ignore
     * @class
     */
    JUI.Class('Taskbar', {
<span id='-method-constructor'>        /**
</span>         * 构造函数
         * @constructor
         */
        init: function () {
            this.wins = [];
        }
        , add: function (winView) {
            this.wins.push(winView);
            this.calcPosition();
        }
        , del: function (winView) {
            this.remove(winView);
            this.calcPosition();
        }
        , calcPosition: function () {
            var nextOffsetLeft = 0;
            var windowHeight = $(window).height();

            for (var i = 0, len = this.wins.length; i &lt; len; i++) {
                var winView = this.wins[i];
                if (winView) {
                    var titleSize = this.buildTitleSize(winView);

                    winView.animateMove(nextOffsetLeft, windowHeight - titleSize.height);
                    nextOffsetLeft += titleSize.width;
                }
            }
        }
        , indexOf: function (winView) {
            for (var i = 0, len = this.wins.length; i &lt; len; i++) {
                if (this.wins[i] == winView) {
                    return i;
                }
            }
            return -1;
        }
        , remove: function (winView) {
            var index = this.indexOf(winView);
            if (index &gt; -1) {
                this.wins.splice(index, 1);
            }
        }
        // 计算标题宽度
        , buildTitleSize: function (winView) {
            var titleBarClass = 'pui-dialog-titlebar';
            var $titleBar = winView.getWin().find('.pui-dialog-titlebar').eq(0);

            var titleTxtWidth = $titleBar.find('.pui-dialog-title').innerWidth();
            var titleTxtHeight = $titleBar.innerHeight();

            var tagAWidth = 0;
            var space = 40;

            var $tagA = $titleBar.find('a');
            $tagA.each(function () {
                tagAWidth += $(this).innerWidth();
            });

            var finalWith = titleTxtWidth + space + tagAWidth;

            return {width: finalWith, height: titleTxtHeight};
        }
    });

})();</pre>
</body>
</html>
